﻿@model Jingxing.Models.Admin.TitleEditModel
@{
    ViewBag.Title = "警兴 - " +Model.Caption ;
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<link href="@Url.Content("~/Scripts/ueditor/themes/default/ueditor.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/ueditor/editor_config.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/ueditor/editor_ui_all_min.js")" type="text/javascript"></script>
<script type="text/javascript">
    var editor;
    var hasRun = false;
    var i = 0;
    $(document).ready(function () {
        i++;
        var isReturn = $(".isReturn").val();
        if (isReturn == 'true' && i == 1) {
            return;
        }
        if (hasRun) {
            return;
        }

        $('#editor').hide();

        editor = new baidu.editor.ui.Editor({
            UEDITOR_HOME_URL: '../../Scripts/ueditor/',
            iframeCssUrl: '../../Scripts/ueditor/themes/default/iframe.css',
            autoClearinitialContent: true,
            initialContent: '<span style="color:#ccc">请输入内容</span>',
            elementPathEnabled: false,
            minFrameHeight: 400
        });
        editor.render('editor');
        if ($(".content").attr("value") != "") {
            var str = $(".content").attr("value");
            editor.setContent(str);
        }

        $(".myDatePickerClass").datepicker({
            buttonImage: '@Url.Content("~/Content/image/calendar.gif")',               
            dateFormat: 'yy/mm/dd',                 
            showOn: 'button',               
            buttonImageOnly: true ,
            changeMonth:true,              
            changeYear:true,
        });  

        $('#editor').show();
        hasRun = true;


        $("label[for=DateTime]").addClass("ui-input-text");
    });
    function sumbit() {
        $(".content").attr("value", editor.getContent());
        $("form").submit();
    }
</script>
@using (Html.BeginForm(new { act = "submit"}))
{
    @Html.HiddenFor(m => m.IsNew)
    @Html.HiddenFor(m => m.Type)
    @Html.HiddenFor(m => m.ID)
    @Html.HiddenFor(m => m.Content, new { @class = "content" })
    @Html.HiddenFor(m => m.IsReturn, new { @class = "isReturn" })
    <div class="ui-body ui-body-a">
        <div data-role="fieldcontain">
            @Html.LabelFor(m => m.Title)
            @Html.TextBoxFor(m => m.Title, new Dict() { "data-mini:true" })
            @Html.ValidationMessageFor(m => m.Title, new { style = "color:Red" })
        </div>
        <div data-role="fieldcontain">
            @Html.LabelFor(m => m.DateTime)
            @Html.TextBox("DateTime", Model.DateTime.ToString("d"), new Dict() { "data-mini:true", "class:myDatePickerClass" })
            @Html.ValidationMessageFor(m => m.DateTime, new { style = "color:Red" })
        </div>
        <div data-role="fieldcontain">
            @Html.LabelFor(m => m.Seq)
            @Html.TextBoxFor(m => m.Seq, new Dict() { "data-mini:true" })
            @Html.ValidationMessageFor(m => m.Seq, new { style = "color:Red" })
        </div>
        <div data-role="fieldcontain">
            <div id='editor'>
            </div>
        </div>
        <div data-role="fieldcontain">
            <input type="button" value="确认" onclick="sumbit()" data-inline="true" data-mini="true" data-ajax="false"/>
        </div>
    </div>
}